<?php

// PAYMENT GATEWAY INTEGRATION SYSTEM BUILD BY MARK FAIL

$gatway[1]['name'] 	= "Paypal Gateway";
$gatway[1]['function'] 	= "gateway_paypal";
$gatway[1]['fields'] 	= array(
							'1' => array(
											'name' => 'Enable Gateway', 
											'type' => 'listbox', 
											'fieldname' => 'gateway_paypal',
											'list' => array(
												'yes'=>'Enable','no'=>'Disable',
											)
										   ),
							
							'2' => array(
											'name' => 'Paypal Email', 'type' => 'text', 'fieldname' => 'paypal_email'
										   ),
							'3' => array(
											'name' => 'Return URL', 'type' => 'text', 'fieldname' => 'paypal_return'
										   ),
							'4' => array(
											'name' => 'Cancel URL', 'type' => 'text', 'fieldname' => 'paypal_cancel'
										   ),
							'5' => array(
											'name' => 'Notify URL', 'type' => 'text', 'fieldname' => 'paypal_notify'
										   ),
							'6' => array(
											'name' => 'Currency Code', 'type' => 'text', 'fieldname' => 'paypal_currency'
										   ),
							'7' => array(
											'name' => 'Display Name', 'type' => 'text', 'fieldname' => 'gateway_paypal_name', 'default' => 'Pay Now with PayPal'
										   ),
							'8' => array(
											'name' => 'Display Icon', 'type' => 'text', 'fieldname' => 'gateway_paypal_icon',
										   ),
);

$gatway[2]['name'] 	= "Worldpay Gateway";
$gatway[2]['function'] 	= "gateway_worldpay";
$gatway[2]['fields'] 	= array(
							'1' => array(
											'name' => 'Enable Gateway', 
											'type' => 'listbox', 
											'fieldname' => 'gateway_worldpay',
											'list' => array(
												'yes'=>'Enable','no'=>'Disable',
											)
										   ),
							
							'2' => array(
											'name' => 'Install ID', 'type' => 'text', 'fieldname' => 'worldpay_instId'
										   ),
							'3' => array(
											'name' => 'Account ID', 'type' => 'text', 'fieldname' => 'worldpay_accId1'
										   ),
							'4' => array(
											'name' => 'Currency Code', 'type' => 'text', 'fieldname' => 'worldpay_currency'
										   ),
							'5' => array(
											'name' => 'Test Mode (101 or 100)', 'type' => 'text', 'fieldname' => 'worldpay_testmode'
										   ),
							'6' => array(
											'name' => 'Display Name', 'type' => 'text', 'fieldname' => 'gateway_worldpay_name', 'default' => 'Pay Now with Worldpay'
										   ),
							'7' => array(
											'name' => 'Display Icon', 'type' => 'text', 'fieldname' => 'gateway_worldpay_icon',
										   ),
);


$gatway[3]['name'] 	= "Bank Transfer";
$gatway[3]['function'] 	= "gateway_bank";
$gatway[3]['fields'] 	= array(
							'1' => array(
											'name' => 'Enable Gateway', 
											'type' => 'listbox', 
											'fieldname' => 'gateway_bank',
											'list' => array(
												'yes'=>'Enable','no'=>'Disable',
											)
										   ),
							
							'2' => array(
											'name' => 'Link to Bank Information Page', 'type' => 'text', 'fieldname' => 'bank_link'
										   ),
							'3' => array(
											'name' => 'Display Name', 'type' => 'text', 'fieldname' => 'gateway_bank_name', 'default' => 'Pay Now with Bank Transfer'
										   ),
							'4' => array(
											'name' => 'Display Icon', 'type' => 'text', 'fieldname' => 'gateway_bank_icon',
										   ),

);


$gatway[4]['name'] 	= "Google Checkout";
$gatway[4]['function'] 	= "gateway_google";
$gatway[4]['fields'] 	= array(
							'1' => array(
											'name' => 'Enable Gateway', 
											'type' => 'listbox', 
											'fieldname' => 'gateway_google',
											'list' => array(
												'yes'=>'Enable','no'=>'Disable',
											)
										   ),
							
							'2' => array(
											'name' => 'Merchant ID', 'type' => 'text', 'fieldname' => 'google_merchant'
										   ),
							'3' => array(
											'name' => 'Currency Code', 'type' => 'text', 'fieldname' => 'google_currency'
										   ),
							'4' => array(
											'name' => 'Display Name', 'type' => 'text', 'fieldname' => 'gateway_google_name', 'default' => 'Pay Now with Google Checkout'
										   ),
							'5' => array(
											'name' => 'Display Icon', 'type' => 'text', 'fieldname' => 'gateway_google_icon',
										   ),

);

$gatway[5]['name'] 	= "Custom Gateway Setup";
$gatway[5]['function'] 	= "gateway_custom";
$gatway[5]['fields'] 	= array(
							'1' => array(
											'name' => 'Enable Gateway', 
											'type' => 'listbox', 
											'fieldname' => 'gateway_custom',
											'list' => array(
												'yes'=>'Enable','no'=>'Disable',
											)
										   ),
							
							'2' => array(
											'name' => 'Form POST Link', 'type' => 'text', 'fieldname' => 'custom_form'
										   ),
							'3' => array(
											'name' => 'Forum Hidden Values', 'type' => 'textarea', 'fieldname' => 'custom_data'
										   ),
							'4' => array(
											'name' => 'Display Name', 'type' => 'text', 'fieldname' => 'gateway_custom_name', 'default' => 'Pay Now'
										   ),
							'5' => array(
											'name' => 'Display Icon', 'type' => 'text', 'fieldname' => 'gateway_custom_icon',
										   ),

);

$gatway[6]['name'] 	= "Authorize.net Setup";
$gatway[6]['function'] 	= "gateway_authorize";
$gatway[6]['fields'] 	= array(
							'1' => array(
											'name' => 'Enable Gateway', 
											'type' => 'listbox', 
											'fieldname' => 'gateway_authorize',
											'list' => array(
												'yes'=>'Enable','no'=>'Disable',
											)
										   ),
							
							'2' => array(
											'name' => 'Login ID', 'type' => 'text', 'fieldname' => 'authorize_loginID'
										   ),
							'3' => array(
											'name' => 'Transaction Key', 'type' => 'text', 'fieldname' => 'authorize_transactionID'
										   ),
							'4' => array(
											'name' => 'Display Name', 'type' => 'text', 'fieldname' => 'gateway_authorize_name', 'default' => 'Pay Now Using Authorize.net'
										   ),
							'5' => array(
											'name' => 'Display Icon', 'type' => 'text', 'fieldname' => 'gateway_authorize_icon',
										   ),

							'6' => array(
											'name' => 'Callback URL', 'type' => 'text', 'fieldname' => 'authorize_callback',
										   ),
);


$gatway[7]['name'] 	= "Protx / SegPay Setup";
$gatway[7]['function'] 	= "gateway_protx";
$gatway[7]['fields'] 	= array(
							'1' => array(
											'name' => 'Enable Gateway', 
											'type' => 'listbox', 
											'fieldname' => 'gateway_protx',
											'list' => array(
												'yes'=>'Enable','no'=>'Disable',
											)
										   ),							
										
							'3' => array(
											'name' => 'Display Name', 'type' => 'text', 'fieldname' => 'gateway_protx_name', 'default' => 'Pay Now Using Protx'
										   ),
							'4' => array(
											'name' => 'Display Icon', 'type' => 'text', 'fieldname' => 'gateway_protx_icon',
										   ),
							'5' => array(
											'name' => 'Vendor Name', 'type' => 'text', 'fieldname' => 'protx_vendor'
										   ),
							'6' => array(
											'name' => 'Currency Code', 'type' => 'text', 'fieldname' => 'protx_currency'
										   ),
							'7' => array(
											'name' => 'Success URL', 'type' => 'text', 'fieldname' => 'protx_success'
										   ),
							'8' => array(
											'name' => 'Failure URL', 'type' => 'text', 'fieldname' => 'protx_fail'
										   ),
							'9' => array(
											'name' => 'Encryption Password', 'type' => 'text', 'fieldname' => 'protx_key'
										   ),

);

$gatway[8]['name'] 	= "CC Avenue Setup";
$gatway[8]['function'] 	= "gateway_ccavenue";
$gatway[8]['fields'] 	= array(
							'1' => array(
											'name' => 'Enable Gateway', 
											'type' => 'listbox', 
											'fieldname' => 'gateway_ccavenue',
											'list' => array(
												'yes'=>'Enable','no'=>'Disable',
											)
										   ),
							
							'2' => array(
											'name' => 'Merchant ID', 'type' => 'text', 'fieldname' => 'ccavenue_merchantID'
										   ),
							'3' => array(
											'name' => 'Redirect URL', 'type' => 'text', 'fieldname' => 'ccavenue_url'
										   ),
							'4' => array(
											'name' => 'Display Name', 'type' => 'text', 'fieldname' => 'gateway_ccavenue_name', 'default' => 'Pay Now Using CCavenue'
										   ),
							'5' => array(
											'name' => 'Display Icon', 'type' => 'text', 'fieldname' => 'gateway_ccavenue_icon',
										   ),
							'6' => array(
											'name' => 'Working Key', 'type' => 'text', 'fieldname' => 'ccavenue_key',
										   ),

);

$gatway[9]['name'] 	= "Alertpay Setup";
$gatway[9]['function'] 	= "gateway_alertpay";
$gatway[9]['fields'] 	= array(
							'1' => array(
											'name' => 'Enable Gateway', 
											'type' => 'listbox', 
											'fieldname' => 'gateway_alertpay',
											'list' => array(
												'yes'=>'Enable','no'=>'Disable',
											)
										   ),
							
							'2' => array(
											'name' => 'Account No.', 'type' => 'text', 'fieldname' => 'alertpay_merchantID'
										   ),
							'3' => array(
											'name' => 'SubAcc No', 'type' => 'text', 'fieldname' => 'alertpay_subID'
										   ),
							'4' => array(
											'name' => 'Display Name', 'type' => 'text', 'fieldname' => 'gateway_alertpay_name', 'default' => 'Pay Now Using AlertPay'
										   ),
							'5' => array(
											'name' => 'Display Icon', 'type' => 'text', 'fieldname' => 'gateway_alertpay_icon',
										   ),
							'6' => array(
											'name' => 'Currency Code', 'type' => 'text', 'fieldname' => 'alertpay_currency', 'default' => 'USD'
										   ),
							'7' => array(
											'name' => 'Cancel URL', 'type' => 'text', 'fieldname' => 'alertpay_fail',
										   ),
							'8' => array(
											'name' => '(thank you) Return URL', 'type' => 'text', 'fieldname' => 'alertpay_success',
										   ),

);

$gatway[10]['name'] 	= "eWay Setup";
$gatway[10]['function'] 	= "gateway_eWay";
$gatway[10]['fields'] 	= array(
							'1' => array(
											'name' => 'Enable Gateway', 
											'type' => 'listbox', 
											'fieldname' => 'gateway_eWay',
											'list' => array(
												'yes'=>'Enable','no'=>'Disable',
											)
										   ),
							
							'2' => array(
											'name' => 'Customer ID', 'type' => 'text', 'fieldname' => 'eWay_customerID'
										   ),
							'4' => array(
											'name' => 'Display Name', 'type' => 'text', 'fieldname' => 'gateway_eWay_name', 'default' => 'Pay Now Using eWay'
										   ),
							'5' => array(
											'name' => 'Display Icon', 'type' => 'text', 'fieldname' => 'gateway_eWay_icon',
										   ),
							
							'6' => array(
											'name' => 'Cancel URL', 'type' => 'text', 'fieldname' => 'eWay_fail',
										   ),
							'7' => array(
											'name' => '(thank you) Return URL', 'type' => 'text', 'fieldname' => 'eWay_returnURL',
										   ),

);

$gatway[11]['name'] 	= "2checkout Setup";
$gatway[11]['function'] 	= "gateway_2checkout";
$gatway[11]['fields'] 	= array(
							'1' => array(
											'name' => 'Enable Gateway', 
											'type' => 'listbox', 
											'fieldname' => 'gateway_2checkout',
											'list' => array(
												'yes'=>'Enable','no'=>'Disable',
											)
										   ),
							
							'2' => array(
											'name' => 'Customer SID', 'type' => 'text', 'fieldname' => '2checkout_customerID'
										   ),
							'4' => array(
											'name' => 'Display Name', 'type' => 'text', 'fieldname' => 'gateway_2checkout_name', 'default' => 'Pay Now Using 2checkout'
										   ),
							'5' => array(
											'name' => 'Display Icon', 'type' => 'text', 'fieldname' => 'gateway_2checkout_icon', 'default' => 'https://www.2checkout.com/images/2cocc04.gif'
										   ),
							
							'6' => array(
											'name' => 'Cancel URL', 'type' => 'text', 'fieldname' => '2checkout_fail',
										   ),
							'7' => array(
											'name' => '(thank you) Return URL', 'type' => 'text', 'fieldname' => '2checkout_returnURL',
										   ),
							'8' => array(
											'name' => 'Product ID', 'type' => 'text', 'fieldname' => '2checkout_productID',
										   ),

);


$gatway[12]['name'] 	= "PayFast Setup";
$gatway[12]['function'] 	= "gateway_payfast";
$gatway[12]['fields'] 	= array(
							'1' => array(
											'name' => 'Enable Gateway', 
											'type' => 'listbox', 
											'fieldname' => 'gateway_payfast',
											'list' => array(
												'yes'=>'Enable','no'=>'Disable',
											)
										   ),
							
							'2' => array(
											'name' => 'Merchant ID', 'type' => 'text', 'fieldname' => 'payfast_ID'
										   ),
							'3' => array(
											'name' => 'Merchant Key', 'type' => 'text', 'fieldname' => 'payfast_key'
										   ),										   
							'4' => array(
											'name' => 'Display Name', 'type' => 'text', 'fieldname' => 'gateway_payfast_name', 'default' => 'Pay Now Using payfast'
										   ),
							'5' => array(
											'name' => 'Display Icon', 'type' => 'text', 'fieldname' => 'gateway_payfast_icon',
										   ),
							
							'6' => array(
											'name' => 'Cancel URL', 'type' => 'text', 'fieldname' => 'payfast_fail',
										   ),
							'7' => array(
											'name' => '(thank you) Return URL', 'type' => 'text', 'fieldname' => 'payfast_return',
										   ),

);

$gatway[13]['name'] 	= "PayWeb Setup";
$gatway[13]['function'] 	= "gateway_payweb";
$gatway[13]['fields'] 	= array(
							'1' => array(
											'name' => 'Enable Gateway', 
											'type' => 'listbox', 
											'fieldname' => 'gateway_payweb',
											'list' => array(
												'yes'=>'Enable','no'=>'Disable',
											)
										   ),
							
							'2' => array(
											'name' => 'Pay Web ID', 'type' => 'text', 'fieldname' => 'payweb_ID'
										   ),
							'3' => array(
											'name' => 'Encryption Key', 'type' => 'text', 'fieldname' => 'payweb_key'
										   ),										   
							'4' => array(
											'name' => 'Display Name', 'type' => 'text', 'fieldname' => 'gateway_payweb_name', 'default' => 'Pay Now Using payweb'
										   ),
							'5' => array(
											'name' => 'Display Icon', 'type' => 'text', 'fieldname' => 'gateway_payweb_icon',
										   ),
							
							'6' => array(
											'name' => '(thank you) Return URL', 'type' => 'text', 'fieldname' => 'payweb_return',
										   ),

);

$gatway[14]['name'] 	= "iDeal Setup";
$gatway[14]['function'] 	= "gateway_ideal";
$gatway[14]['fields'] 	= array(
							'1' => array(
											'name' => 'Enable Gateway', 
											'type' => 'listbox', 
											'fieldname' => 'gateway_ideal',
											'list' => array(
												'yes'=>'Enable','no'=>'Disable',
											)
										   ),
							
							'2' => array(
											'name' => 'Pay Web ID', 'type' => 'text', 'fieldname' => 'ideal_ID'
										   ),
												   
							'4' => array(
											'name' => 'Display Name', 'type' => 'text', 'fieldname' => 'gateway_ideal_name', 'default' => 'Pay Now Using iDeal'
										   ),
							'5' => array(
											'name' => 'Display Icon', 'type' => 'text', 'fieldname' => 'gateway_ideal_icon',
										   ),
							
							'6' => array(
											'name' => '(thank you) Return URL', 'type' => 'text', 'fieldname' => 'ideal_return',
										   ),

);

$gatway[15]['name'] 	= "Paypal Payments Pro Setup";
$gatway[15]['function'] 	= "gateway_paypalpro";
$gatway[15]['fields'] 	= array(
							'1' => array(
											'name' => 'Enable Gateway', 
											'type' => 'listbox', 
											'fieldname' => 'gateway_paypalpro',
											'list' => array(
												'yes'=>'Enable','no'=>'Disable',
											)
										   ),
							
							'2' => array(
											'name' => 'Username', 'type' => 'text', 'fieldname' => 'paypalpro_username'
										   ),
												   
							'4' => array(
											'name' => 'Password', 'type' => 'text', 'fieldname' => 'paypalpro_password', 
										   ),
							'5' => array(
											'name' => 'Signature', 'type' => 'text', 'fieldname' => 'paypalpro_sig',
										   ),
							
							'6' => array(
											'name' => 'Callback Page URL', 'type' => 'text', 'fieldname' => 'paypalpro_callback',
										   ),
							'7' => array(
											'name' => 'Currency Code', 'type' => 'text', 'fieldname' => 'paypalpro_currency', 'default' => 'USD'
										   ),

);

$gatway[16]['name'] 	= "eWAY API Setup";
$gatway[16]['function'] 	= "gateway_ewayAPI";
$gatway[16]['fields'] 	= array(
							'1' => array(
											'name' => 'Enable Gateway', 
											'type' => 'listbox', 
											'fieldname' => 'gateway_ewayAPI',
											'list' => array(
												'yes'=>'Enable','no'=>'Disable',
											)
										   ),
							
							'2' => array(
											'name' => 'Customer ID', 'type' => 'text', 'fieldname' => 'ewayAPI_customerID'
										   ), 
							'3' => array(
											'name' => 'Payment Method', 
											'type' => 'listbox', 
											'fieldname' => 'ewayAPI_paymentmethod',
											'list' => array(
												'REAL_TIME'=>'Real Time','REAL_TIME_CVN'=>'Real Time CVN','GEO_IP_ANTI_FRAUD'=>'GEO Anti Fraud',
											)
										   ),
						'4' => array(
											'name' => 'Live or Test', 
											'type' => 'listbox', 
											'fieldname' => 'ewayAPI_live',
											'list' => array(
												'true'=>'Live Gateway','false'=>'Test Gateway',
											)
										   ),
							
							'5' => array(
											'name' => 'Callback Page URL', 'type' => 'text', 'fieldname' => 'ewayAPI_callback',
										   ), 

);

// ---------------------------- GATEWAY FIELD CODE ------------------------

 
function MakeField($type, $name, $value, $list="", $default=""){

if($value ==""){ $value = $default; }
	switch($type){
	
		case "checkbox": { return  "<input type='checkbox' class='checkbox' name='".$name."' value='".$value."'> "; } break;
	
		case "text": { return  "<input type='text' name='adminArray[".$name."]' value='".$value."' style='width:500px;'>"; } break;

		case "textarea": { return "<textarea name='adminArray[".$name."]' type='text' style='width:550px; height:150px;'>".stripslashes($value)."</textarea>"; } break;


		case "listbox": { 

			$r ="<select name='adminArray[".$name."]' style='width: 150px;'>";
			foreach($list as $key => $val){
				if($value==$key){ $sel="selected"; }else{ $sel=""; }
				$r .="<option value='".$key."' ".$sel.">".$val."</option>";
			}
			$r .="</select>";
			return $r;

		} break;

	}

}

// ---------------------------- GATEWAY CODE ------------------------

function gateway_paypal($data=""){

	global $wpdb;
 
	$gatewaycode = "";

	$gatewaycode .= '<form method="post" action="https://www.paypal.com/cgi-bin/webscr" name="checkout_paypal">';

	if($_POST['rec'] == 1){

		$gatewaycode .= '<input type="hidden" name="cmd" value="_xclick-subscriptions">
		<input type="hidden" name="a3" value="'.$data['price']['total'].'">';

		if(!isset($_POST['rec_days'])){
				$gatewaycode .= '<input type="hidden" name="p3" value="1">
				<input type="hidden" name="t3" value="M">
				<input type="hidden" name="src" value="1">
				<input type="hidden" name="sra" value="1">';
		}else{

			if($_POST['rec_days'] < 8){

			$gatewaycode .= '<input type="hidden" name="a3" value="'.$data['price']['total'].'">		
			<input type="hidden" name="p3" value="'.$_POST['rec_days'].'">
			<input type="hidden" name="t3" value="D">
			<input type="hidden" name="src" value="1">
			<input type="hidden" name="sra" value="1">';

			}elseif($_POST['rec_days'] < 30){

			$numweeks = $_POST['rec_days']/7;
			$gatewaycode .= '<input type="hidden" name="a3" value="'.$data['price']['total'].'">
			<input type="hidden" name="p3" value="'.$numweeks.'">
			<input type="hidden" name="t3" value="W">
			<input type="hidden" name="src" value="1">
			<input type="hidden" name="sra" value="1">';

			}elseif($_POST['rec_days'] < 370){

			$nummonths = $_POST['rec_days']/30;							 							  	
			$gatewaycode .= '<input type="hidden" name="a3" value="'.$data['price']['total'].'">	
			<input type="hidden" name="p3" value="'.$nummonths.'">	
			<input type="hidden" name="t3" value="M">
			<input type="hidden" name="src" value="1">
			<input type="hidden" name="sra" value="1">';		
			}
		}

		
	}else{
		$gatewaycode .= '<input type="hidden" name="cmd" value="_xclick">
		<input type="hidden" name="amount" value="'.$data['price']['total'].'">';
	}

	$gatewaycode .= '
	<input type="hidden" name="return" value="'.get_option('paypal_return').'?order_id='.$data['orderid'].'">
	<input type="hidden" name="cancel_return" value="'.get_option('paypal_cancel').'">
	<input type="hidden" name="notify_url" value="'.get_option('paypal_notify').'">	
	<input type="hidden" name="item_name" value="'.strip_tags($data['description']).'">
	<input type="hidden" name="item_number" value="'.$data['orderid'].'">
	<input type="hidden" name="business" value="'.get_option('paypal_email').'">
	<input type="hidden" name="currency_code" value="'.get_option('paypal_currency').'">
	<input type="hidden" name="custom" value="'.$data['orderid'].'">
	<p class="CheckoutBtn"><a href="javascript:document.checkout_paypal.submit();">'.SPEC($GLOBALS['_LANG']['_checkout']) .'</a></p>

	</form>';

	return $gatewaycode;

}

function gateway_worldpay($data=""){

	global $wpdb;

	$gatewaycode = "";

	$gatewaycode = '<form name="checkout_worldpay" target="_top" method="post" action="https://select.worldpay.com/wcc/purchase">	
	<input type="hidden" name="amount" value="'.$data['price']['total'].'" >
	<input type="hidden" name="instId" value="'.get_option('worldpay_instId').'">
	<input type="hidden" name="accId1" value="'.get_option('worldpay_accId1').'">
	<input type="hidden" name="cartId" value="'.$data['orderid'].'">
	<input type="hidden" name="desc" value="'.strip_tags($data['description']).'">
	<input type="hidden" name="currency" value="'.get_option('worldpay_currency').'">
	<input name="testMode" value="'.get_option('worldpay_testmode').'" type="hidden">

	<p class="CheckoutBtn"><a href="javascript:document.checkout_worldpay.submit();">'.SPEC($GLOBALS['_LANG']['_checkout']) .'</a></p>

	</form>';

	return $gatewaycode;

}

function gateway_bank($data=""){

	global $wpdb;


	$gatewaycode = '<p class="CheckoutBtn"><a href="javascript:location.href=\''.get_option('bank_link').'\'">'.SPEC($GLOBALS['_LANG']['_checkout']) .'</a></p>';

	return $gatewaycode;

}

function gateway_google($data=""){

	global $wpdb;


	$gatewaycode = "";

	$gatewaycode = '<form method="POST"  action="https://checkout.google.com/api/checkout/v2/checkoutForm/Merchant/'.get_option('google_merchant').'" name="checkout_google" accept-charset="utf-8">

  <input type="hidden" name="item_name_1" value="'.$data['orderid'].'"/>
  <input type="hidden" name="item_description_1" value="'.strip_tags($data['description']).'"/>
  <input type="hidden" name="item_quantity_1" value="1"/>
  <input type="hidden" name="item_price_1" value="'.$data['price']['total'].'"/>
  <input type="hidden" name="item_currency_1" value="'.get_option('google_currency').'"/>
 
	  <input type="hidden" name="_charset_"/>

	 <p class="CheckoutBtn"><a href="javascript:document.checkout_google.submit();">'.SPEC($GLOBALS['_LANG']['_checkout']) .'</a></p>
	
	  </form>';

	return $gatewaycode;

}

function gateway_custom($data=""){

	global $wpdb;


	// CUSTOM REPLACE
	$PaymentButton = str_replace("(orderid)",$data['orderid'],get_option('custom_data'));
	$PaymentButton = str_replace("(amount)",$data['price']['total'],$PaymentButton);
	$PaymentButton = str_replace("(description)",strip_tags($data['description']),$PaymentButton);
	$PaymentButton = str_replace('\"','"',$PaymentButton);
	$PaymentButton = str_replace('(city)',strip_tags($data['billing']['city']),$PaymentButton);
	$PaymentButton = str_replace('(email)',strip_tags($data['billing']['email']),$PaymentButton);
	$PaymentButton = str_replace('(fname)',strip_tags($data['billing']['fname']),$PaymentButton);
	$PaymentButton = str_replace('(lname)',strip_tags($data['billing']['lname']),$PaymentButton);
	$PaymentButton = str_replace('(address1)',strip_tags($data['billing']['address1']),$PaymentButton);
	$PaymentButton = str_replace('(address2)',strip_tags($data['billing']['address2']),$PaymentButton);
	$PaymentButton = str_replace('(phone)',strip_tags($data['billing']['phone']),$PaymentButton);
	$PaymentButton = str_replace('(country)',strip_tags($data['billing']['country']),$PaymentButton);


	$gatewaycode = "";

	$gatewaycode = '<form method="POST" action="'.get_option('custom_form').'" name="checkout_custom">'.$PaymentButton.'

	 <p class="CheckoutBtn"><a href="javascript:document.checkout_custom.submit();">'.SPEC($GLOBALS['_LANG']['_checkout']) .'</a></p>
	
	  </form>';

	return $gatewaycode;

}


function gateway_authorize($data=""){

	global $wpdb;

	$gatewaycode = "";

	$gatewaycode = '<form name="gateway_authorize" target="_top" method="post" action="https://secure.authorize.net/gateway/transact.dll">';

	$gatewaycode .='
	<input type="hidden" name="x_amount" value="'.$data['price']['total'].'" >
	<input type="hidden" name="x_login" value="'.get_option('authorize_loginID').'">
	<input type="hidden" name="x_description" value="'.strip_tags($data['description']).'">
	<input type="hidden" name="x_cust_ID" value="'.$data['orderid'].'">
	<input type="hidden" name="x_receipt_link_url" value="'.get_option('authorize_callback').'?order_id='.$data['orderid'].'">	
	<input type="hidden" name="x_show_form" value="PAYMENT_FORM">';

	// create figure print for authoize.net
	$loginID			= get_option('authorize_loginID');
	$transactionKey 	= get_option('authorize_transactionID');
	$sequence			= rand(1, 1000);
	$timeStamp			= time ();
				
	if( phpversion() >= '5.1.2' )
	{	
	$fingerprint = hash_hmac("md5", $loginID . "^" . $sequence . "^" . $timeStamp . "^" . $data['price']['total'] . "^", $transactionKey); 
	}
	else 
	{ 
	$fingerprint = bin2hex(mhash(MHASH_MD5, $loginID . "^" . $sequence . "^" . $timeStamp . "^" . $data['price']['total'] . "^", $transactionKey)); 
	}
 
	 
	$gatewaycode .='<input type="hidden" name="amount" value="'.$data['price']['total'].'" >
	<input type="hidden" name="x_fp_sequence" value="'.$sequence.'">
	<input type="hidden" name="x_fp_hash" value="'.$fingerprint.'"> 
	<input type="hidden" name="x_fp_timestamp" value="'.$timeStamp.'">
	<p class="CheckoutBtn"><a href="javascript:document.gateway_authorize.submit();">'.SPEC($GLOBALS['_LANG']['_checkout']) .'</a></p>

	</form>';

	return $gatewaycode;

}

function gateway_protx($data=""){

	global $wpdb;
 
	$gatewaycode = '<form name="gateway_protx" target="_top" method="post" action="https://live.sagepay.com/Simulator/VSPFormGateway.asp">';

	$gatewaycode .='<input type="hidden" name="VPSProtocol" value="2.23">
	<input type="hidden" name="TxType" value="PAYMENT">
	<input type="hidden" name="Vendor" value="'.get_option('protx_vendor').'">
	<input type="hidden" name="navigate" value="" />';

	/** Okay, build the crypt field for Form using the information in our session **
	*** First we need to generate a unique VendorTxCode for this transaction **
	*** We're using VendorName, time stamp and a random element.  You can use different methods if you wish **
	*** but the VendorTxCode MUST be unique for each transaction you send to Server **/
		
		$intRandNum = rand(0,32000)*rand(0,32000);
		$strVendorTxCode= get_option('protx_vendor') . $intRandNum;

	// Now to build the Form crypt field.  For more details see the Form Protocol 2.23 
	$strPost="VendorTxCode=" . $strVendorTxCode; /** As generated above **/
	$strPost=$strPost . "&Amount=" . $data['price']['total']; // Formatted to 2 decimal places with leading digit
	$strPost=$strPost . "&Currency=" . get_option('protx_currency');
	// Up to 100 chars of free format description
	$strPost=$strPost . "&Description=Online Order From " . get_option('protx_vendor');
	
	/* The SuccessURL is the page to which Form returns the customer if the transaction is successful 
	** You can change this for each transaction, perhaps passing a session ID or state flag if you wish */
	$strPost=$strPost . "&SuccessURL=" . get_option('protx_success').'?order_id='.$data['orderid'];
	
	/* The FailureURL is the page to which Form returns the customer if the transaction is unsuccessful
	** You can change this for each transaction, perhaps passing a session ID or state flag if you wish */
	$strPost=$strPost . "&FailureURL=" . get_option('protx_fail');
	
	// This is an Optional setting. Here we are just using the Billing names given.
	$strPost=$strPost . "&CustomerName=" . $data['billing']['fname'] . " " . $data['billing']['lname'];
 
	// Billing Details:
	$strPost=$strPost . "&BillingFirstnames=." . $data['billing']['fname'];
	$strPost=$strPost . "&BillingSurname=." . $data['billing']['lname'];
	$strPost=$strPost . "&BillingAddress1=." . $data['billing']['address'];
	 
	$strPost=$strPost . "&BillingCity=." . $data['billing']['city'];
	$strPost=$strPost . "&BillingPostCode=AB101F";// . $data['billing']['postcode'];
	$strPost=$strPost . "&BillingCountry=UK"; //$data['billing']['country']
	
	// Delivery Details:
	$strPost=$strPost . "&DeliveryFirstnames=." . $data['billing']['fname'];
	$strPost=$strPost . "&DeliverySurname=." . $data['billing']['lname'];
	$strPost=$strPost . "&DeliveryAddress1=." . $data['billing']['address'];
	$strPost=$strPost . "&DeliveryCity=." . $data['billing']['city'];
	$strPost=$strPost . "&DeliveryPostCode=AB101F";// . $data['billing']['postcode'];
	$strPost=$strPost . "&DeliveryCountry=UK" ; //$data['billing']['country']
	
	$strPost=$strPost . "&Basket=" . $strBasket; // As created above 
	
	// For charities registered for Gift Aid, set to 1 to display the Gift Aid check box on the payment pages
	$strPost=$strPost . "&AllowGiftAid=0";
 		
	/* Allow fine control over 3D-Secure checks and rules by changing this value. 0 is Default 
	** It can be changed dynamically, per transaction, if you wish.  See the Form Protocol document */
	$strPost=$strPost . "&Apply3DSecure=0";
	// Encrypt the plaintext string for inclusion in the hidden field
 
	$strCrypt = base64Encode(SimpleXor($strPost,get_option('protx_key')));

	$gatewaycode .='<input type="hidden" name="Crypt" value="'.$strCrypt.'" >

	<p class="CheckoutBtn"><a href="javascript:document.gateway_protx.submit();">'.SPEC($GLOBALS['_LANG']['_checkout']) .'</a></p>

	</form>';

	return $gatewaycode;


}

function simpleXor($InString, $Key) {
  // Initialise key array
  $KeyList = array();
  // Initialise out variable
  $output = "";
  
  // Convert $Key into array of ASCII values
  for($i = 0; $i < strlen($Key); $i++){
    $KeyList[$i] = ord(substr($Key, $i, 1));
  }

if(strlen($InString) > 1){
  // Step through string a character at a time
  for($i = 0; $i < strlen($InString); $i++) {
    // Get ASCII code from string, get ASCII code from key (loop through with MOD), XOR the two, get the character from the result
    // % is MOD (modulus), ^ is XOR
    $output.= chr(ord(substr($InString, $i, 1)) ^ ($KeyList[$i % strlen($Key)]));
  }
}
  // Return the result
  return $output;
}
 

/* Base 64 Encoding function **
** PHP does it natively but just for consistency and ease of maintenance, let's declare our own function **/

function base64Encode($plain) {
  // Initialise output variable
  $output = "";
  
  // Do encoding
  $output = base64_encode($plain);
  
  // Return the result
  return $output;
}

/* Base 64 decoding function **
** PHP does it natively but just for consistency and ease of maintenance, let's declare our own function **/

function base64Decode($scrambled) {
  // Initialise output variable
  $output = "";
  
  // Fix plus to space conversion issue
  $scrambled = str_replace(" ","+",$scrambled);
  
  // Do encoding
  $output = base64_decode($scrambled);
  
  // Return the result
  return $output;
}






function gateway_ccavenue($data=""){

	global $wpdb;

	$gatewaycode = "";

	$gatewaycode = '<form name="gateway_ccavenue" target="_top" method="post" action="https://www.ccavenue.com/shopzone/cc_details.jsp">';


	$Merchant_Id = get_option('ccavenue_merchantID');//This id(also User Id)  available at "Generate Working Key" of "Settings & Options" 
	$Amount = $data['price']['total'] ;//your script should substitute the amount in the quotes provided here
	$Order_Id = $data['orderid'];//your script should substitute the order description in the quotes provided here
	$Redirect_Url = get_option('ccavenue_url') ;//your redirect URL where your customer will be redirected after authorisation from CCAvenue

	$WorkingKey = get_option('ccavenue_key') ;//put in the 32 bit alphanumeric key in the quotes provided here.Please note that get this key ,login to your CCAvenue merchant account and visit the "Generate Working Key" section at the "Settings & Options" page. 
	$Checksum = getCheckSum($Merchant_Id,$Amount,$Order_Id ,$Redirect_Url,$WorkingKey);

	$gatewaycode .='
	<input type=hidden name=Merchant_Id value="'.get_option('ccavenue_merchantID').'">
	<input type=hidden name=Amount value="'.$data['price']['total'].'">
	<input type=hidden name=Order_Id value="'.$data['orderid'].'">
	<input type=hidden name=Redirect_Url value="'.get_option('ccavenue_url').'">
	<input type=hidden name=Checksum value="'.$Checksum.'">
	<input type="hidden" name="billing_cust_name" value="'.$data['billing']['fname'].' '.$data['billing']['lname'].'"> 
	<input type="hidden" name="billing_cust_address" value="'.$data['billing']['address'].'"> 
	<input type="hidden" name="billing_cust_country" value="'.$data['billing']['country'].'"> 
	<input type="hidden" name="billing_cust_state" value="'.$data['billing']['state'].'"> 
	<input type="hidden" name="billing_zip" value="'.$data['billing']['postcode'].'"> 
	<input type="hidden" name="billing_cust_tel" value="'.$data['billing']['phone'].'"> 
	<input type="hidden" name="billing_cust_email" value="'.$data['billing']['email'].'"> 
	<input type="hidden" name="delivery_cust_name" value="'.$data['billing']['fname'].'"> 
	<input type="hidden" name="delivery_cust_address" value="'.$data['billing']['address'].'"> 
	<input type="hidden" name="delivery_cust_country" value="'.$data['billing']['country'].'"> 
	<input type="hidden" name="delivery_cust_state" value="'.$data['billing']['state'].'"> 
	<input type="hidden" name="delivery_cust_tel" value="'.$data['billing']['phone'].'"> 
	<input type="hidden" name="delivery_cust_notes" value=""> 
	<input type="hidden" name="Merchant_Param" value=""> 
	<input type="hidden" name="billing_cust_city" value="'.$data['billing']['city'].'"> 
	<input type="hidden" name="billing_zip_code" value="'.$data['billing']['postcode'].'"> 
	<input type="hidden" name="delivery_cust_city" value="'.$data['billing']['city'].'"> 
	<input type="hidden" name="delivery_zip_code" value="'.$data['billing']['postcode'].'">  

	<p class="CheckoutBtn"><a href="javascript:document.gateway_ccavenue.submit();">'.SPEC($GLOBALS['_LANG']['_checkout']) .'</a></p>

	</form>';

	return $gatewaycode;

}
 function getchecksum($MerchantId,$Amount,$OrderId ,$URL,$WorkingKey)
{
	$str ="$MerchantId|$OrderId|$Amount|$URL|$WorkingKey";
	$adler = 1;
	$adler = adler32($adler,$str);
	return $adler;
}

function adler32($adler , $str)
{
	$BASE =  65521 ;

	$s1 = $adler & 0xffff ;
	$s2 = ($adler >> 16) & 0xffff;
	for($i = 0 ; $i < strlen($str) ; $i++)
	{
		$s1 = ($s1 + Ord($str[$i])) % $BASE ;
		$s2 = ($s2 + $s1) % $BASE ;
			//echo "s1 : $s1 <br /> s2 : $s2 <br />";

	}
	return leftshift($s2 , 16) + $s1;
}

function leftshift($str , $num)
{

	$str = DecBin($str);

	for( $i = 0 ; $i < (64 - strlen($str)) ; $i++)
		$str = "0".$str ;

	for($i = 0 ; $i < $num ; $i++) 
	{
		$str = $str."0";
		$str = substr($str , 1 ) ;
		//echo "str : $str <br />";
	}
	return cdec($str) ;
}

function cdec($num)
{

	for ($n = 0 ; $n < strlen($num) ; $n++)
	{
	   $temp = $num[$n] ;
	   $dec =  $dec + $temp*pow(2 , strlen($num) - $n - 1);
	}

	return $dec;
}


function gateway_alertpay($data=""){

	global $wpdb;

	$gatewaycode = "";

	$gatewaycode = '<form name="gateway_alertpay" target="_top" method="post" action="https://www.alertpay.com/PayProcess.aspx">';


$gatewaycode .='<input type="hidden" name="ap_merchant" value="'.get_option('alertpay_merchantID').'" >
<input type="hidden" name="ap_amount" value="'.$data['price']['total'].'">
<input type="hidden" name="ap_itemname" value=" ORDER ID: '.$data['orderid'].'"> 
<input type="hidden" name="ap_description" value="'.strip_tags($data['description']).'" >
<input type="hidden" name="ap_returnurl" value="'.get_option('alertpay_success').'?order_id='.$data['orderid'].'">
<input type="hidden" name="ap_cancelurl" value="'.get_option('alertpay_fail').'"> 
<input type="hidden" name="ap_itemcode" value="'.$data['orderid'].'"> 
<input type="hidden" name="ap_quantity" value="1" >
<input type="hidden" name="ap_currency" value="'.get_option('alertpay_currency').'">
<input type="hidden" name="ap_test" value="0"> 
<input type="hidden" name="ap_purchasetype" value="service"> 

	<p class="CheckoutBtn"><a href="javascript:document.gateway_alertpay.submit();">'.SPEC($GLOBALS['_LANG']['_checkout']) .'</a></p>

	</form>';

	return $gatewaycode;

}

function gateway_eWay($data=""){

	global $wpdb;

$total = str_replace(".","",$data['price']['total']);
if(strlen($total) == 3){ $total .=0; }
if(strlen($total) == 1 || strlen($total) == 2){ $total .="00"; }
	$gatewaycode = "";

	$gatewaycode = '<form method="post" name="gateway_eWay" action="https://www.eway.com.au/gateway/payment.asp">';
 
	$gatewaycode .='	
	<input type="hidden" name="ewayCustomerID" value="'.get_option('eWay_customerID').'" />
	<input type="hidden" name="ewayTotalAmount" value="'.$total.'" />
	<input type="hidden" name="ewayCustomerFirstName" value="'.$data['billing']['fname'].'" />
	<input type="hidden" name="ewayCustomerLastName" value="'.$data['billing']['lname'].'" />
	<input type="hidden" name="ewayCustomerEmail" value="'.$data['billing']['email'].'" />
	<input type="hidden" name="ewayCustomerAddress" value="'.$data['billing']['address'].'" />
	<input type="hidden" name="ewayCustomerPostcode" value="'.$data['billing']['postcode'].'" />
	<input type="hidden" name="ewayCustomerInvoiceDescription" value="'.strip_tags($data['description']).'" />
	<input type="hidden" name="ewayCustomerInvoiceRef" value="'.$data['orderid'].'" />
	<input type="hidden" name="ewayURL" value="'.get_option('eWay_returnURL').'?order_id='.$data['orderid'].'" />
	<input type="hidden" name="ewaySiteTitle" value="My Web Site" />
	<input type="hidden" name="ewayTrxnNumber" value="'.$data['orderid'].'" />
	<input type="hidden" name="ewayOption1" value="'.$data['orderid'].'" />
	<input type="hidden" name="ewayOption2" value="" />
	<input type="hidden" name="ewayOption3" value="" />
	<input type="hidden" name="ewayCVN" value="123" />
	<p class="CheckoutBtn"><a href="javascript:document.gateway_eWay.submit();">'.SPEC($GLOBALS['_LANG']['_checkout']) .'</a></p>

	</form>';

	return $gatewaycode;

}


function gateway_bluepay($data=""){


$gatewaycode = '<form action="https://secure.bluepay.com/interfaces/bp10emu" method=POST name="gateway_bluepay"> 
	<input type=hidden name=MERCHANT value="demo"> 
	<input type=hidden name=TRANSACTION_TYPE value="AUTH"> 
	<input type=hidden name=REBILLING value="1"> 
	<input type=hidden name=REB_FIRST_DATE value="1 MONTH"> 
	<input type=hidden name=REB_EXPR value="1 MONTH"> 
	<input type=hidden name=REB_CYCLES value="11"> 
	<input type=hidden name=REB_AMOUNT value="5.00"> 
	<input type=hidden name=TAMPER_PROOF_SEAL value="????"> 
	<input type=hidden name=AMOUNT value="'.$data['price']['total'].'"> 
	<input type=hidden name=Order_ID value="'.$data['orderid'].'"> 
	<input type=hidden name=APPROVED_URL value="http://momandpop.com/goodpay.html"> 
	<input type=hidden name=DECLINED_URL value="http://momandpop.com/badpay.html"> 
	<input type=hidden name=MISSING_URL value="http://momandpop.com/error.html"> 
	<input type=hidden name=COMMENT value="SUBSCRIPTION TO WIDGET OF THE MONTH 
	CLUB, 1YR"> 
	 
	<table> 
	<tr><td>Card number</td><td><input type=text name=CC_NUM value=""></td></tr> 
	<tr><td>CVV2</td><td><input type=text name=CVCCVV2 value=""></td></tr> 
	<tr><td>Expiration Date</td><td><input type=text name=CC_EXPIRES value=""></td></tr> 
	<tr><td>NAME</td><td><input type=text name=NAME value=""></td></tr> 
	<tr><td>Address</td><td><input type=text name=Addr1 value=""></td></tr> 
	<tr><td>Address 2</td><td><input type=text name=Addr2></td></tr>> 
	<tr><td>City</td><td><input type=text name=CITY value=""></td></tr> 
	<tr><td>State</td><td><input type=text name=STATE value=""></td></tr> 
	<tr><td>Zipcode</td><td><input type=text name=ZIPCODE value=""></td></tr> 
	<tr><td>Phone</td><td><input type=text name=PHONE value=""></td></tr> 
	<tr><td>Email</td><td><input type=text name=EMAIL value=""></td></tr> 
	<tr><td colspan=2><input type=SUBMIT value="Test it." name=SUBMIT></td></tr> 
	</table> 
	
	<p class="CheckoutBtn"><a href="javascript:document.gateway_bluepay.submit();">'.SPEC($GLOBALS['_LANG']['_checkout']) .'</a></p>
	 
	</form>';
	
	return $gatewaycode;


}


function gateway_2checkout($data=""){

$gatewaycode ="<form action='https://www.2checkout.com/checkout/purchase' method='post' name='gateway_2checkout'>
<input type='hidden' name='sid' value='".get_option('2checkout_customerID')."' >
<input type='hidden' name='total' value='".$data['price']['total']."' >
<input type='hidden' name='cart_order_id' value='".$data['orderid']."' >
<input type='hidden' name='id_type' value='1' >
<input type='hidden' name='sh_cost' value='0.00' >
<input type='hidden' name='c_prod' value='".strip_tags($data['description'])."' >
<input type='hidden' name='c_name' value='Product 10' >
<input type='hidden' name='c_description' value='".strip_tags($data['description'])."' >
<input type='hidden' name='c_price' value='1.00' >
";

$gatewaycode .= '<p class="CheckoutBtn"><a href="javascript:document.gateway_2checkout.submit();">'.SPEC($GLOBALS['_LANG']['_checkout']) .'</a></p>
</form>';

return $gatewaycode;


//get_option('2checkout_fail')
//get_option('2checkout_returnURL')

}

function gateway_payfast($data=""){

$gatewaycode = '<form action="https://www.payfast.co.za/eng/process" method="post" name="gateway_payfast">

<!-- Receiver Details -->
<input type="hidden" name="merchant_id" value="'.get_option('payfast_ID').'">
<input type="hidden" name="merchant_key" value="'.get_option('payfast_key').'">
<input type="hidden" name="return_url" value="'.get_option('payfast_return').'">
<input type="hidden" name="cancel_url" value="'.get_option('payfast_fail').'">
<input type="hidden" name="notify_url" value="'.get_option('payfast_return').'">

<!-- Payer Details -->
<input type="hidden" name="name_first" value="'.$data['billing']['fname'].'">
<input type="hidden" name="name_last" value="'.$data['billing']['lname'].'">
<input type="hidden" name="email_address" value="'.$data['billing']['email'].'">

<!-- Transaction Details -->
<input type="hidden" name="m_payment_id" value="'.$data['orderid'].'">
<input type="hidden" name="amount" value="'.$data['price']['total'].'">
<input type="hidden" name="item_name" value="'.strip_tags($data['description']).'">
<input type="hidden" name="item_description" value="'.strip_tags($data['description']).'">

<!-- Transaction Options -->
<input type="hidden" name="email_confirmation" value="">

<!-- Security -->
<input type="hidden" name="signature" value="">';


$gatewaycode .= '<p class="CheckoutBtn"><a href="javascript:document.gateway_payfast.submit();">'.SPEC($GLOBALS['_LANG']['_checkout']) .'</a></p>
</form>';

return $gatewaycode;


}


function gateway_payweb($data=""){

    $PAYGATE_ID			= get_option('payweb_ID');
    $REFERENCE			= "Cart ID: ".$data['orderid'];
	
	$num = number_format($data['price']['total'],2, '.', ',');
	
    $AMOUNT				= str_replace(".","",str_replace(",","",$num));
    $CURRENCY			= "ZAR";
    $RETURN_URL			= get_option('payweb_return');
    $TRANSACTION_DATE	= gmstrftime("%Y-%m-%d %H:%M");
    $EMAIL 				= $data['billing']['email'];
    $encryption_key 	= get_option('payweb_key');

    $checksum_source 	= $PAYGATE_ID."|".$REFERENCE."|".$AMOUNT."|".$CURRENCY."|".$RETURN_URL."|".$TRANSACTION_DATE."|";
    $checksum_source 	.= $EMAIL."|";
    $checksum_source 	.= $encryption_key;
    $CHECKSUM 			= md5($checksum_source);
	
$gatewaycode = '<form action="https://www.paygate.co.za/paywebv2/process.trans" method="post" name="gateway_payweb">
<input type="hidden" name="AMOUNT" 		value="'.$AMOUNT.'">
<input type="hidden" name="CHECKSUM" 	value="'.$CHECKSUM.'">
<input type="hidden" name="EMAIL" 		value="'.$data['billing']['email'].'">
<input type="hidden" name="TRANSACTION_DATE" value="'.$TRANSACTION_DATE.'">
<input type="hidden" name="RETURN_URL" 	value="'.$RETURN_URL.'">
<input type="hidden" name="CURRENCY" 	value="'.$CURRENCY.'">
<input type="hidden" name="REFERENCE" 	value="'.$REFERENCE.'">
<input type="hidden" name="PAYGATE_ID" 	value="'.$PAYGATE_ID.'">';
$gatewaycode .= '<p class="CheckoutBtn"><a href="javascript:document.gateway_payweb.submit();">'.SPEC($GLOBALS['_LANG']['_checkout']) .'</a></p>
</form>';

return $gatewaycode;


}

function gateway_ideal($data=""){

require_once('gateway_ideal/ideal.class.php');
$partner_id  = get_option('ideal_ID'); // Uw mollie partner ID
$iDEAL = new iDEAL_Payment ($partner_id);
//$iDEAL->setTestMode();
$bank_array = $iDEAL->getBanks();

if ($bank_array == false)
{
	echo '<p>Er is een fout opgetreden bij het ophalen van de banklijst: ', $iDEAL->getErrorMessage(), '</p>';
	exit;
}

?>
<form method="post">
<input type="hidden" name="amount" value="<?php echo $data['price']['total']; ?>" />
<input type="hidden" name="desc" value="<?php echo strip_tags($data['description']); ?>" />
<select name="bank_id">
<option value=''>Kies uw bank</option>		
<?php foreach ($bank_array as $bank_id => $bank_name) { ?>
		<option value="<?php echo $bank_id ?>"><?php echo $bank_name ?></option>
<?php } ?>
</select>
<input type="submit" name="submit" value="Betaal via iDEAL" />
</form>

<?php
}


function gateway_paypalpro($data=""){ ?>
 

<form method="POST" action="<?php echo get_option('paypalpro_callback'); ?>">
<input type="hidden" name="paymentType" value="instant" />
<input type="hidden" name="gateway" value="paypalpro" />
<input type="hidden" name="amount" value="<?php echo $data['price']['total']; ?>">
<input type="hidden" value="0" name="recurring">
<input type="hidden" value="<?php echo $data['orderid']; ?>" name="paypal_order_id">
<div style="width:580px;clear:both;">

<h2>Payment Details</h2>
<hr>
<br />
<div class="row"><label class="col1">First Name:</label>
<span class="col2"><input  class="mid2" type=text size=30 maxlength=32 name="firstName" value="<?php echo $data['billing']['fname']; ?>"></span>
</div>
<div class="row"><label class="col1">Last Name:</label>
<span class="col2"><input class="mid2"  type=text size=30 maxlength=32 name=lastName value="<?php echo $data['billing']['flname']; ?>"></span>
</div>
<div class="row"><label class="col1">Card Type:</label>
<span class="col2"><select  class="mid2" name=creditCardType onChange="javascript:generateCC(); return false;">
				<option value=Visa selected>Visa</option>
				<option value=MasterCard>MasterCard</option>
				<option value=Discover>Discover</option>
				<option value=Amex>American Express</option>
			</select></span>
</div>
<div class="row"><label class="col1">Card Number:</label>
<span class="col2"><input  class="mid2" type=text size=19 maxlength=19 name="creditCardNumber"></span>
</div>
<div class="row"><label class="col1">Expiration Date:</label>
<span class="col2"><select  class="mid2" name=expDateMonth>
				<option value=1>01</option>
				<option value=2>02</option>
				<option value=3>03</option>
				<option value=4>04</option>
				<option value=5>05</option>
				<option value=6>06</option>
				<option value=7>07</option>
				<option value=8>08</option>
				<option value=9>09</option>
				<option value=10>10</option>
				<option value=11>11</option>
				<option value=12>12</option>
			</select>
			<select  class="mid2" name=expDateYear>
				<option value=2005>2005</option>
				<option value=2006>2006</option>
				<option value=2007>2007</option>
				<option value=2008>2008</option>
				<option value=2009>2009</option>
				<option value=2010 selected>2010</option>
				<option value=2011>2011</option>
				<option value=2012>2012</option>
				<option value=2013>2013</option>
				<option value=2014>2014</option>
				<option value=2015>2015</option>
			</select></span>
</div>
<div class="row"><label class="col1">Card Verification Number:</label>
<span class="col2"><input  class="mid2" type=text size=3 maxlength=4 name=cvv2Number></span>
</div>
<div class="clear"></div>
<br />
<h2>Billing Address:</h2>
<hr>
<br />
<div class="clear"></div>
<div class="row"><label class="col1">Address 1:</label>
<span class="col2"><input  class="mid2" type=text size=25 maxlength=100 name=address1 value="<?php echo $data['billing']['address']; ?>"></span>
</div>
<div class="row"><label class="col1">Address 2:</label>
<span class="col2"><input  class="mid2" type=text  size=25 maxlength=100 name=address2 value="<?php echo $data['billing']['address1']; ?>">(optional)</span>
</div>
<div class="row"><label class="col1">City:</label>
<span class="col2"><input  class="mid2" type=text size=25 maxlength=40 name=city value="<?php echo $data['billing']['city']; ?>"></span>
</div>
<div class="row"><label class="col1">State:</label>
<span class="col2"><select  class="mid2" id=state name=state>
				<option value=></option>
				<option value=AK>AK</option>
				<option value=AL>AL</option>
				<option value=AR>AR</option>
				<option value=AZ>AZ</option>
				<option value=CA selected>CA</option>
				<option value=CO>CO</option>
				<option value=CT>CT</option>
				<option value=DC>DC</option>
				<option value=DE>DE</option>
				<option value=FL>FL</option>
				<option value=GA>GA</option>
				<option value=HI>HI</option>
				<option value=IA>IA</option>
				<option value=ID>ID</option>
				<option value=IL>IL</option>
				<option value=IN>IN</option>
				<option value=KS>KS</option>
				<option value=KY>KY</option>
				<option value=LA>LA</option>
				<option value=MA>MA</option>
				<option value=MD>MD</option>
				<option value=ME>ME</option>
				<option value=MI>MI</option>
				<option value=MN>MN</option>
				<option value=MO>MO</option>
				<option value=MS>MS</option>
				<option value=MT>MT</option>
				<option value=NC>NC</option>
				<option value=ND>ND</option>
				<option value=NE>NE</option>
				<option value=NH>NH</option>
				<option value=NJ>NJ</option>
				<option value=NM>NM</option>
				<option value=NV>NV</option>
				<option value=NY>NY</option>
				<option value=OH>OH</option>
				<option value=OK>OK</option>
				<option value=OR>OR</option>
				<option value=PA>PA</option>
				<option value=RI>RI</option>
				<option value=SC>SC</option>
				<option value=SD>SD</option>
				<option value=TN>TN</option>
				<option value=TX>TX</option>
				<option value=UT>UT</option>
				<option value=VA>VA</option>
				<option value=VT>VT</option>
				<option value=WA>WA</option>
				<option value=WI>WI</option>
				<option value=WV>WV</option>
				<option value=WY>WY</option>
				<option value=AA>AA</option>
				<option value=AE>AE</option>
				<option value=AP>AP</option>
				<option value=AS>AS</option>
				<option value=FM>FM</option>
				<option value=GU>GU</option>
				<option value=MH>MH</option>
				<option value=MP>MP</option>
				<option value=PR>PR</option>
				<option value=PW>PW</option>
				<option value=VI>VI</option>
			</select></span>
</div>

<div class="row"><label class="col1">ZIP Code:</label>
<span class="col2"><input  class="mid2" type=text size=10 maxlength=10 name=zip value="<?php echo $data['billing']['postcode']; ?>">(5 or 9 digits)</span>
</div>

<br /><br /><br /><br />
<div class="clear"></div>
<center><input name="" type="submit" value="Process Payment" style="font-size:18px;"></center>

 </div>
</form>
 
 
<script language="javascript">
	generateCC();
</script>

<?php }
 
 
function gateway_ewayAPI($data=""){

$total = str_replace(".","",$data['price']['total']);
if(strlen($total) == 3){ $total .=0; }
if(strlen($total) == 1 || strlen($total) == 2){ $total .="00"; }
?>

<form id="Form1" method="post" action="" ENCTYPE="multipart/form-data">
<input name="cid" type="hidden" id="txtInvDesc" value="<?php echo get_option('ewayAPI_customerID'); ?>" />
<input name="txtInvDesc" type="hidden" id="txtInvDesc" value="<?php echo $data['orderid']; ?>" />
<input name="txtInvRef" type="hidden" id="txtInvRef" value="<?php echo $data['orderid']; ?>"/>
<input name="txtTxnNumber" type="hidden" id="txtTxnNumber" value="<?php echo $data['orderid']; ?>"/>
<input name="txtAmount" type="hidden" id="txtAmount" value="<?php echo $total; ?>" />
<input name="callback" type="hidden" value="<?php echo get_option('ewayAPI_callback').'?order_id='.$data['orderid'] ?>" />
<input name="emethod" type="hidden" value="<?php echo get_option('ewayAPI_paymentmethod') ?>" />
<input name="elive" type="hidden" value="<?php echo get_option('ewayAPI_live') ?>" />

<div style="width:580px;clear:both;">

<h2>Payment Details</h2>
<hr>
<br />
<div class="row"><label class="col1">First Name:</label>
<span class="col2"><input class="mid2" name="txtFirstName" type="text" id="txtFirstName" value="<?php echo $data['billing']['fname']; ?>" /></span></div>

<div class="row"><label class="col1">Last Name:</label>
<span class="col2"><input class="mid2" name="txtLastName" type="text" id="txtLastName" value="<?php echo $data['billing']['lname']; ?>" /></span></div>

<div class="row"><label class="col1">Email Address:</label>
<span class="col2"><input class="mid2" name="txtEmail" type="text" id="txtEmail" value="<?php echo $data['billing']['email']; ?>" /></span></div>

<div class="row"><label class="col1">Address:</label>
<span class="col2"><input class="mid2" name="txtAddress" type="text" id="txtAddress" value="<?php echo $data['billing']['address']; ?>" /></span></div>

<div class="row"><label class="col1">Postcode:</label>
<span class="col2"><input class="mid2" name="txtPostcode" type="text" id="txtPostcode" value="<?php echo $data['billing']['postcode']; ?>" /></span>
 <br />
 
 
<div class="clear"></div>

<div class="row"><label class="col1">Card Type:</label>
<span class="col2"><select class="mid2" name="ddlCardType" id="ddlCardType">
		<option value="VISA">VISA</option>
		<option value="MASTERCARD">MASTERCARD</option>
		<option value="AMEX">AMEX</option>
	</select></span></div>

<div class="row"><label class="col1">Card Holders Name:</label>
<span class="col2"><input class="mid2" name="txtCCName" type="text" id="txtCCName" /></span></div>

<div class="row"><label class="col1">Card Number:</label>
<span class="col2"><input class="mid2" name="txtCCNumber" type="text" maxlength="17" id="txtCCNumber" /></span></div>
 

<div class="row"><label class="col1">Card CSV Number: <br /><small>(3 digits on the back)</small></label>
<span class="col2"><input class="mid2" name="txtCSVNumber" type="text" maxlength="5" id="txtCSVNumber"  style="width:20px;"/></span></div>

<div class="row"><label class="col1">Card Expiry:</label>
<span class="col2"><select class="mid2" name="ddlExpiryMonth" id="ddlExpiryMonth">
		<option value="01">01</option>
		<option value="02">02</option>
		<option value="03">03</option>
		<option value="04">04</option>
		<option value="05">05</option>
		<option value="06">06</option>
		<option value="07">07</option>
		<option value="08">08</option>
		<option value="09">09</option>
		<option value="10">10</option>
		<option value="11">11</option>
		<option value="12">12</option>
	</select>
<select class="mid2" name="ddlExpiryYear" id="ddlExpiryYear">
		<option value="10">10</option>
		<option value="11">11</option>
		<option value="12">12</option>
		<option value="13">13</option>
		<option value="14">14</option>
		<option value="15">15</option>
		<option value="16">16</option>
		<option value="17">17</option>
	</select></span></div>



 

<center><input type="submit" name="btnProcess" value="Process Transaction" id="btnProcess"  style="font-size:18px;" /></center>
</div> 
</form>


<?php
 
}

?>